//==============================================================================
// PrintUtils.cc
// ----------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
// $Id: PrintUtils.cc,v 1.2 2000/03/31 19:33:00 kdurbin Exp $
//------------------------------------------------------------------------------
// $Log: PrintUtils.cc,v $
// Revision 1.2  2000/03/31 19:33:00  kdurbin
// *** empty log message ***
//
//
//
//==============================================================================
//.......1.........2.........3.........4.........5.........6.........7.........8
//

#include "PrintUtils.hh"


//---------------------------------------------------
// * GetDateStamp
//---------------------------------------------------
// Gets the current date as a string in the format:
// 
// yyyymmdd  
//
// Example:  20020814
// 
//
string GetDateStamp(){
  char buf[500];
  time_t rawtime;
  struct tm *timeinfo;

  time(&rawtime);
  timeinfo = localtime(&rawtime);

  int fullYear = timeinfo->tm_year+1900;
  int month = timeinfo->tm_mon + 1;
  int day = timeinfo->tm_mday;

  sprintf(buf,"%04d%02d%02d",fullYear,month,day);
  string rValue = buf;
  return(rValue);
}


//---------------------------------------------------
// * PrintSpacePaddedNum
//---------------------------------------------------
// Prints a number followed by a number of spaces 
// inversely proportional to the number's length. 
// 
//
void PrintSpacePaddedNum(ostream &fout,int colWidth,int num)
{
  char buf[500];
  sprintf(buf,"%d",num);
  string NumString = buf;

  int numSpaces = colWidth - NumString.size();
  if (numSpaces > 0){
	 for(int i = 0;i<numSpaces;i++){
		NumString = " "+NumString;
	 }
  }
  fout<<NumString;
}

//---------------------------------------------------
// * PrintSpacePaddedFloat
//---------------------------------------------------
// Prints a number followed by a number of spaces 
// inversely proportional to the number's length. 
// KJD Needs to take #digits input parameter. 
// 
//
void PrintSpacePaddedFloat(ostream &fout,int colWidth,float num)
{
  char buf[500];
  sprintf(buf,"%3.3f",num);
  string NumString = buf;

  int numSpaces = colWidth - NumString.size();
  if (numSpaces > 0){
	 for(int i = 0;i<numSpaces;i++){
		NumString = " "+NumString;
	 }
  }
  fout<<NumString;
}

//---------------------------------------------------
// * PrintSpacePaddedString
//---------------------------------------------------
// Prints a number followed by a number of spaces 
// inversely proportional to the number's length. 
// 
//
void PrintSpacePaddedString(ostream &fout,int colWidth,string s)
{
  int numSpaces = colWidth - s.size();
  if (numSpaces > 0){
	 for(int i = 0;i<numSpaces;i++){
		s = s+" ";
	 }
  }
  fout<<s;
}




















